package com.easytopit.demo.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.easytopit.demo.domain.Cinema;
import com.easytopit.demo.exception.BizException;
import com.easytopit.demo.service.CinemaService;

/**
 * @author YWQ
 *
 */
@Controller
public class CinemaController {

	@Autowired
	private CinemaService cinemaService;
	
	@RequestMapping("/cinemaControllerAdd.do")
	public String add(String name,String address,String phone,String features,Integer quantity,String hallName,
			Double score,HttpServletRequest request,HttpServletResponse response,ModelMap map) throws BizException{
		Cinema add = cinemaService.add(name, address, phone, features, quantity, hallName, score);
		if (add != null) {
			map.put("message", "录入成功");
		}
		return "";
	}
	
	@RequestMapping("/cinemaControllerUpdate.do")
	public String update(@RequestParam("name") String name,@RequestParam("address") String address,
			@RequestParam("phone") String phone,@RequestParam("features") String features,
			@RequestParam("quantity") Integer quantity,@RequestParam("hallName") String hallName,
			@RequestParam("score") Double score,HttpServletRequest request,HttpServletResponse response,
				ModelMap map) throws BizException{
		
		Integer update = cinemaService.update(name, address, phone, features, quantity, hallName, score);
		if (update != null) {
			map.put("message", "修改成功");
		}
		return "";
	}
}